package com.mes.service.jy;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mes.dao.jy.DaysheduDetailMapper;
import com.mes.entity.jy.DaysheduDetail;
import com.mes.entity.jy.Queryjy;

/**
 * @ClassName: DaysheduDetailServiseImpl 
 * @Description:排产单业务层实现类
 * @Author jy
 * @Date 2018年1月15日 下午2:36:55 
 * @version 1.0
 */
@Service
@Transactional
public class DaysheduDetailServiseImpl implements DaysheduDetailServise{

	@Resource
	private DaysheduDetailMapper daysheduDetailMapper;
	
	@Override
	public int createDaysheduDetail(DaysheduDetail daysheduDetail) {
		
		//根据生产单号和产品id查询详情表中是否已存在此信息
		DaysheduDetail daysheduDetail2 = daysheduDetailMapper.selectDaysheduDetailByMany(daysheduDetail);
				
				if(daysheduDetail2 == null) {
					//不存在就新增保存此数据
					return daysheduDetailMapper.createDaysheduDetail(daysheduDetail);
				}
					//存在就修改此数据（存在时生产计划单编号和产品id都存在）
					return daysheduDetailMapper.updateDaysheduDetaile(daysheduDetail);
	}

	@Override
	public List<DaysheduDetail> selectDaysheduDetailByDnum(String dayshedunum) {
		return daysheduDetailMapper.selectDaysheduDetailByDnum(dayshedunum);
	}

	@Override
	public int countDaysheduDetail(String dayshedunum) {
		return daysheduDetailMapper.countDaysheduDetail(dayshedunum);
	}

	@Override
	public int editWstape(DaysheduDetail dayshedudetail) {
		return daysheduDetailMapper.editWstape(dayshedudetail);
	}

	@Override
	public int countDysheduDetailByAllw(Queryjy queryjy) {
		return daysheduDetailMapper.countDysheduDetailByAllw(queryjy);
	}

	@Override
	public List<DaysheduDetail> selectDysheduDetailByAllw(Queryjy queryjy) {
		return daysheduDetailMapper.selectDysheduDetailByAllw(queryjy);
	}

	@Override
	public void deleteDaysheduNumNotin() {
		daysheduDetailMapper.deleteDaysheduNumNotin();
	}

	@Override
	public List<DaysheduDetail> selectDaysheduDetailByDnum2(String dayshedunum) {
		return daysheduDetailMapper.selectDaysheduDetailByDnum2(dayshedunum);
	}
	
}
